 class Student {
    private String name;
    private int age;
    // 无参构造方法
    public Student () {
    }
    // 带参构造方法
    public Student (String name, int age) {
        this.name = name;
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    @Override
    public String toString () {
        return "姓名:" + name + ", 年龄:" + age;
    }
}
class StudentClass {
    private String name;
    private int number;
    private Student[] member = new Student[50];
    // 无参构造方法
    public StudentClass () {
    }
    // 带参构造方法
    public StudentClass (String name, int number) {
        this.name = name;
        this.number = number;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getNumber() {
        return number;
    }
    public void setNumber(int number) {
        this.number = number;
    }
    public Student[] getMember() {
        return member;
    }
    public void setMember(Student[] member) {
        this.member = member;
    }
    public void addStudent (Student s) {
        if (number < 50) {
            member [number] = s;
            number++;
        } else {
            System.out.println ("本班已经有 50 名学生，无法添加。");
        }
    }
    public void showMsg () {
        System.out.println ("班级名称:" + name);
        System.out.println ("班级学生人数:" + number);
        for (int i = 0; i < number; i++) {
            System.out.println (member [i].toString ());
        }
    }
}
 class Test02 {
    public static void main (String [] args) {
        StudentClass sc = new StudentClass ();
        sc.setName ("软工 2001 班");
        Student s1 = new Student ();
        s1.setName ("张三");
        s1.setAge (20);
        Student s2 = new Student ("李四", 21);
        Student s3 = new Student ("王五", 22);
        sc.addStudent(s1);
        sc.addStudent(s2);
        sc.addStudent(s3);
        sc.showMsg();
    }
}
